<html>
 <head>
  <meta charset="UTF-8">
 </head>
 <body>
  <h1 data-lake-id="mpF1t" id="mpF1t"><span data-lake-id="u815588f5" id="u815588f5">典型回答</span></h1>
  <p data-lake-id="u8aa4a2f4" id="u8aa4a2f4"><br></p>
  <p data-lake-id="u83642756" id="u83642756"><span data-lake-id="u373da7d2" id="u373da7d2">Dubbo是RPC框架，需要远程调用，那么就需要把请求和响应做序列化和反序列化。Dubbo目前支持多种序列化协议。</span></p>
  <p data-lake-id="u4f68b15a" id="u4f68b15a"><span data-lake-id="u4b9c7308" id="u4b9c7308">​</span><br></p>
  <p data-lake-id="u50dc6d82" id="u50dc6d82"><span data-lake-id="u52ed758c" id="u52ed758c">在</span><a href="https://github.com/apache/dubbo/tree/3.3/dubbo-serialization" target="_blank" data-lake-id="ueab3b966" id="ueab3b966"><span data-lake-id="udfc6376d" id="udfc6376d">Dubbo 3.0</span></a><span data-lake-id="u9b0388b2" id="u9b0388b2"> 中，内置了3种序列化协议：</span></p>
  <p data-lake-id="ude70e17b" id="ude70e17b"><img src="https://cdn.nlark.com/yuque/0/2024/png/5378072/1704532702023-a1278f43-e27b-454b-be83-e59cadb48006.png?x-oss-process=image%2Fwatermark%2Ctype_d3F5LW1pY3JvaGVp%2Csize_13%2Ctext_SmF2YSA4IEd1IFA%3D%2Ccolor_FFFFFF%2Cshadow_50%2Ct_80%2Cg_se%2Cx_10%2Cy_10"></p>
  <p data-lake-id="u520c0b28" id="u520c0b28"><br></p>
  <p data-lake-id="ub175e4f0" id="ub175e4f0"><span data-lake-id="u7177677b" id="u7177677b">比较常见的有：</span></p>
  <p data-lake-id="u90fb5b77" id="u90fb5b77"><span data-lake-id="uc7a28bd8" id="uc7a28bd8">​</span><br></p>
  <ol list="ud6e36533">
   <li fid="u01b964ad" data-lake-id="ub08449ce" id="ub08449ce"><strong><span data-lake-id="ucbf337f9" id="ucbf337f9" class="lake-fontsize-12" style="color: rgb(34, 34, 34)">Hessian2</span></strong><span data-lake-id="u95cf17e6" id="u95cf17e6" class="lake-fontsize-12" style="color: rgb(55, 65, 81)">：</span><span data-lake-id="u3d92c0c9" id="u3d92c0c9">hessian是一种跨语言的高效二进制序列化方式。但这里实际不是原生的hessian2序列化，而是阿里修改过的hessian lite，它是dubbo RPC默认启用的序列化方式</span></li>
   <li fid="u01b964ad" data-lake-id="u9f88806b" id="u9f88806b"><strong><span data-lake-id="u68651183" id="u68651183" class="lake-fontsize-12" style="color: var(--tw-prose-bold)">Java</span></strong><span data-lake-id="u5e5a0ea9" id="u5e5a0ea9" class="lake-fontsize-12" style="color: rgb(55, 65, 81)">：标准的Java序列化协议，易于使用但性能相对较低。</span></li>
   <li fid="u01b964ad" data-lake-id="ufbc9d2da" id="ufbc9d2da"><strong><span data-lake-id="u667a06be" id="u667a06be" class="lake-fontsize-12" style="color: var(--tw-prose-bold)">fastjson2</span></strong><span data-lake-id="ube53decd" id="ube53decd" class="lake-fontsize-12" style="color: rgb(55, 65, 81)">：轻量级的数据交换格式，适用于简单的数据结构，易于阅读和调试。</span></li>
  </ol>
  <p data-lake-id="u6a86beb5" id="u6a86beb5"><span data-lake-id="u304ff870" id="u304ff870" class="lake-fontsize-12" style="color: rgb(55, 65, 81)">​</span><br></p>
  <p data-lake-id="u3b790bee" id="u3b790bee"><span data-lake-id="u9a97787a" id="u9a97787a">这里面，hessian2是默认的，主要是因为他的性能是最好的，并且它支持跨语言。</span></p>
  <p data-lake-id="u73f84d09" id="u73f84d09"><span data-lake-id="u00b2a963" id="u00b2a963">​</span><br></p>
  <p data-lake-id="ueb888097" id="ueb888097"><span data-lake-id="u955ba657" id="u955ba657">而这几年，各种序列化框架层出不穷，今天出了一个号称速度快，明天出一个号称跨语言。总之有很多，于是在</span><a href="https://github.com/apache/dubbo-spi-extensions" target="_blank" data-lake-id="u72004d6f" id="u72004d6f"><span data-lake-id="ud7aeedfd" id="ud7aeedfd">Dubbo的扩展</span></a><span data-lake-id="u6255fa48" id="u6255fa48">中，就增加支持很多其他的序列化协议：</span></p>
  <p data-lake-id="u394fa6af" id="u394fa6af"><span data-lake-id="u089589a9" id="u089589a9" class="lake-fontsize-12" style="color: rgb(55, 65, 81)">​</span><br></p>
  <p data-lake-id="u5e42060a" id="u5e42060a"><img src="https://cdn.nlark.com/yuque/0/2024/png/5378072/1704532830505-c3cefb9f-1ece-484b-b2b1-946738da21ad.png?x-oss-process=image%2Fwatermark%2Ctype_d3F5LW1pY3JvaGVp%2Csize_30%2Ctext_SmF2YSA4IEd1IFA%3D%2Ccolor_FFFFFF%2Cshadow_50%2Ct_80%2Cg_se%2Cx_10%2Cy_10"></p>
  <p data-lake-id="u4b46e609" id="u4b46e609"><span data-lake-id="ub3ebca54" id="ub3ebca54" class="lake-fontsize-12" style="color: rgb(55, 65, 81)">​</span><br></p>
  <p data-lake-id="uc6e7a4da" id="uc6e7a4da"><span data-lake-id="u9bc5242c" id="u9bc5242c" class="lake-fontsize-12" style="color: rgb(55, 65, 81)">​</span><br></p>
  <p data-lake-id="uec1b9ac4" id="uec1b9ac4"><span data-lake-id="u9bd054aa" id="u9bd054aa">其中包括了avro、fastjson、fst、fury、gson、Jackson、kryo、msgpack、protobuf和protostuff等。</span></p>
  <p data-lake-id="u5eaf830a" id="u5eaf830a"><span data-lake-id="u8e853c41" id="u8e853c41">​</span><br></p>
  <p data-lake-id="u640a82b2" id="u640a82b2"><span data-lake-id="uaa759e03" id="uaa759e03">这里面很多框架其实性能都比较好，大有代替Hession的势头，比如Kryo、FST、fury等。</span></p>
  <p data-lake-id="u54618865" id="u54618865"><span data-lake-id="u7aea791a" id="u7aea791a">​</span><br></p>
  <p data-lake-id="u760630ad" id="u760630ad"><span data-lake-id="u2cca746e" id="u2cca746e">比如蚂蚁出的fury框架，号称比hessian快100倍，以下是他的一个整体介绍。详见：</span><a href="https://developer.aliyun.com/article/992485" target="_blank" data-lake-id="u850281b6" id="u850281b6"><span data-lake-id="u479388c6" id="u479388c6">https://developer.aliyun.com/article/992485</span></a></p>
  <p data-lake-id="u7626449d" id="u7626449d"><span data-lake-id="u322d2bcb" id="u322d2bcb">​</span><br></p>
  <p data-lake-id="u083cdd19" id="u083cdd19"><img src="https://cdn.nlark.com/yuque/0/2024/png/5378072/1704533239946-e7a0107a-4e48-42cb-8e3c-54a46795a371.png?x-oss-process=image%2Fwatermark%2Ctype_d3F5LW1pY3JvaGVp%2Csize_31%2Ctext_SmF2YSA4IEd1IFA%3D%2Ccolor_FFFFFF%2Cshadow_50%2Ct_80%2Cg_se%2Cx_10%2Cy_10"></p>
 </body>
</html>